A call stack is a data structure that stores information about the active functions (subroutines) of a computer program. For example, when a function is called, a combination of one or more of a return address, arguments, and local variable(s) is pushed onto the stack. Upon completion of the function, the combination is popped off of the stack. A stack trace is a report of the active stack frames at a point in time during the execution of a computer program. A stack trace enables the tracking of the sequence of nested functions called up to the point when the stack trace is generated.
Similarly, a branch trace is a report of branch instructions executed at a point in time during the execution of a computer program. In response to the execution of a branch instruction, the branch instruction address and/or destination instruction address is saved to memory. A branch trace enables a more detailed tracking of the sequence of instructions executed up to the point when the branch trace is generated.
The context provided by a stack trace or branch trace at a given point in a computer program is useful in debugging. For example, a computer program may record log messages to provide an audit trail that can be used to understand system activity and to diagnose problems. Log messages typically do not include calling context beyond the function from which each log message was called. Saving an entire stack trace or branch trace in log messages is not practical. The log message would lose its brevity and writing these messages would be inefficient. Additionally, saving branch traces is costly in terms of memory and execution speed.